package com.xbongbong.saas.model;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.PaasFormDataEntity;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.domain.entity.UpdateDataEntity;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import com.xbongbong.saas.domain.entity.ext.PaymentTaskEntityExt;

import java.util.List;
import java.util.Map;

/**
 * @author: 汪腾伟
 * @date: 2020/8/3
 * @desrcption: 回款计划接口层
 * @version:1.0
 */
public interface PaymentTaskModel extends IModel<PaymentTaskEntityExt> {

    /**
     * 插入回款计划
     *
     * @param entity 实体
     * @return
     * @throws XbbException
     */
    @Override
    Integer insert(PaymentTaskEntityExt entity) throws XbbException;


    /**
     * 根据数据id和公司id查询具体信息
     *
     * @param formDataId 回款计划id
     * @param corpid 公司id
     * @return
     */
    PaymentTaskEntityExt getByKey(Long formDataId, String corpid);

    /**
     * 删除回款计划
     *
     * @param dataIdList
     * @param corpid
     */
    Integer deleteBatch(List<Long> dataIdList, String corpid) throws XbbException;

    /**
     * 批量更新回款计划
     *
     * @param updateDataEntityList
     * @return
     */
    int batchUpdatePaymentTask(List<UpdateDataEntity> updateDataEntityList, String corpid) throws XbbException;

    /**
     * 根据回款计划id数组获取回款计划信息
     *
     * @param corpid
     * @param dataIdList
     * @return
     */
    List<PaymentTaskEntityExt> getPaymentTaskByIdList(String corpid, List<Long> dataIdList);

    /**
     * 批量新增回款计划
     *
     * @param formDataList
     * @return
     */
    List<PaymentTaskEntityExt> insertBatch(List<PaymentTaskEntityExt> formDataList) throws XbbException;

    /**
     * 批量更新回款计划
     *
     * @param updateList
     * @param corpid
     * @return
     */
    Integer updateBatchForAll(List<? extends PaasFormDataEntity> updateList, String corpid) throws XbbException;

    /**
     * 批量插入新回款计划，包含id，用于资金三期脚本迁移
     *
     * @param paymentTaskEntityExtInsertList
     * @return
     */
    void insertBatchIncludId(List<PaymentTaskEntityExt> paymentTaskEntityExtInsertList) throws XbbException;

    /**
     * 无差别更新回款计划
     *
     * @param paymentTaskEntityExtUpdateList
     * @return
     */
    Integer updateAll(List<PaymentTaskEntityExt> paymentTaskEntityExtUpdateList) throws XbbException;

    List<PaymentTaskEntityExt> findEntitysWithoutSub(Map<String, Object> param);

    /**
     * 编辑更新回款计划的时候需要限制系统给定字段不可编辑
     *
     * @param formatExplainDTO
     */
    void formatUpdateExplain(FormatExplainDTO formatExplainDTO);

    /**
     * 对一些关联数据的处理，客户、合同
     *
     * @param saasAnalysisDataDTO
     * @param result
     */
    void formatData(SaasAnalysisDataDTO saasAnalysisDataDTO, JSONObject result) throws XbbException;
}
